from game import *

import math

def init(game):

    start = StaticBox((8.0, 14.0, 8.0))
    start.set_position((0.0, -7.0, 0.0))
    game.add_object(start)

    m1 = MovingPlatform(10000, (3.0, 0.3, 2.5))
    m1.set_position((0.0, 2.0, -3.0))
    m1.set_texture_name("p2")
    m1.set_linear_vel((0.0, 2.0, 0.0))
    game.add_timer("m1", 5.0, 0.0, m1.reverse)
    game.add_object(m1)
    
    m2 = MovingPlatform(10000, (3.0, 0.3, 2.5))
    m2.set_position((0.0, 22.0, -6.0))
    m2.set_texture_name("p2")
    m2.set_linear_vel((0.0, -2.0, 0.0))
    game.add_timer("m2", 5.0, 0.0, m2.reverse)
    game.add_object(m2)

    p1 = StaticBox((6.0, 4.0, 6.0))
    p1.set_position((0.0, 20.0, -11.0))
    game.add_object(p1)

    
    #game.set_start_pos((0.0, 25.0, -11.0))


    r1 = Platform(1000, (5.0, 5.0, 40.0))
    r1.set_position((0.0, 18.0, -36,0))
    r1.set_angular_vel((0.0, 0.0, 0.3))
    r1.set_texture_name("swirl")
    game.add_object(r1)
    
    r2 = Platform(1000, (40.0, 5.0, 5.0))
    r2.set_position((18.0, 16.0, -61,0))
    r2.set_angular_vel((0.3, 0.0, 0.0))
    r2.set_texture_name("swirl")
    game.add_object(r2)


    r3 = Platform(1000, (10.0, 0.4, 10.0))
    r3.set_position((48.0, 18.0, -61.0))
    r3.set_angular_vel((0.0, 1.5, 0.0))
    r3.set_texture_name("p2")
    game.add_object(r3)

    #game.set_start_pos((48.0, 20.0, -61.0))


    num = 30
    size = 3.0
    for i in range(num):
        b = Platform(0.4, (size, 0.4, 8.0))
        b.set_position((60.0 + i*(size+0.01), 18.0, -61.0))
        b.set_texture_name("ice")
        game.add_object(b)


    num2 = 20
    for i in range(num2):
        b = Platform(0.4, (8.0, 0.4, size))
        b.set_position((58.0 + num*(size+0.01), 18.0, -67.0 + i*(-0.01-size)))
        b.set_texture_name("ice")
        game.add_object(b)


    p2 = StaticBox((10.0, 0.4, 10.0))
    p2.set_position((148.3, 18.0, -134.0))
    game.add_object(p2)


    #game.set_start_pos((148.3, 22.0, -134.0))
    

    r4 = Platform(99999999, (10.0, 0.4, 10.0))
    r4.set_position((148.3, 18.0, -154.0))
    r4.set_angular_vel((0.0, 1.0, 0.0))
    r4.set_texture_name("swirl")
    game.add_object(r4)


    m3 = MovingPlatform(10000, (4.0, 0.3, 3.5))
    m3.set_position((148.3, 20.0, -155.0))
    m3.set_texture_name("p2")
    m3.set_linear_vel((-1.0, 2.0, -0.5))
    game.add_timer("m3", 6.0, 0.0, m3.reverse)
    game.add_object(m3)

    
    p3 = StaticBox((15.0, 25.0, 15.0))
    p3.set_position((142.3, 20.0, -170.0))
    game.add_object(p3)

    #game.set_start_pos((142.3, 35.0, -170.0))

    dx = 0.5
    dy = 2.0

    x = -math.pi
    y = 33.0
    while x <= math.pi:

        z = math.sin(x)
        
        a = 5*x
        b = 9*z
        
        k = Platform(2, (3.0, 1.0, 3.0))
        k.set_position((148.0+a, y, b-170.0))
        k.set_texture_name("ice")
        game.add_object(k)

        y += dy
        x += dx


    g = StaticBox((5.0, 0.5, 5.0))
    g.set_position((162.3, 58.0, -173.0))
    g.set_texture_name("goal")
    game.add_object(g)
